package com.ljc.service;


import com.baomidou.mybatisplus.extension.service.IService;
import com.ljc.model.dto.user.UserRegisterRequest;
import com.ljc.model.entity.User;
import com.ljc.model.vo.UserDevKeyVO;
import com.ljc.model.vo.UserVO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 用户服务
 */
public interface UserService extends IService<User> {

    /**
     * 用户注册
     * @return 新用户id
     */
    User userRegister(UserRegisterRequest userRegisterRequest, HttpServletRequest request, HttpServletResponse response);

    /**
     * 用户登录
     * @return 脱敏后的用户信息
     */
    User userLogin(String userAccount, String userPassword, HttpServletRequest request, HttpServletResponse response);

    /**
     * 获取当前登录用户
     */
    User getLoginUser(HttpServletRequest request);

    /**
     * 通过cookie获取用户
     */
    UserVO getLoginUser(String cookie);

    /**
     * 通过cookie获取第三方登录的用户
     */
    User getLoginUserByOauth2(String cookie);

    /**
     * 是否为管理员
     */
    boolean isAdmin(HttpServletRequest request);

    /**
     * 用户注销
     */
    boolean userLogout(HttpServletRequest request);

    /**
     * 生成图形验证码
     */
    void getCaptcha(HttpServletRequest request, HttpServletResponse response);

    /**
     * 发送短信验证码
     */
    Boolean sendSmsCaptcha(String phoneNum);

    /**
     * 使用手机号登录
     */
    User userLoginBySms(String phoneNum, String phoneCaptcha, HttpServletRequest request, HttpServletResponse response);

    /**
     * 重新生成ak，sk
     */
    UserDevKeyVO genkey(HttpServletRequest request);

    /**
     * 首次生成ak，sk
     */
    UserDevKeyVO genKey(String userAccount);

    /**
     * 初始化登录用户
     */
    User initLoginUser(User originUser, HttpServletResponse response);
}
